<template>
  <el-container class="main-box">
    <el-main ref="Box">
      <el-scrollbar class="person_body">
        <el-card
          v-for="(item, index) in examine_list" :key="index"
          :class="index != examine_list.length-1?'box-card':''"
        >
          <!-- 列表内容  -->
          <div class="audit_data">
            <!--   herder       -->
            <div class="describe">
              <div class="describe_left">
                <p>
                  <svg-icon class="f-s-20" style="color: #1966E2; margin-right: 6px;" class-name="m-r-7"
                            icon-class="appraisegr"
                  />
                  <!--                  <svg-icon class="f-s-24"  style="color: #1966E2;margin-right: 6px;" class-name="m-r-7" icon-class="appraisedr"/>-->
                  <span class="name">{{dynamic<3?item.userName:item.deptName}}</span>
                  <span class="solid"></span>
                </p>
                <p>
                  <span>{{ timeToStr(dynamic,item) }}</span>
                </p>
              </div>
              <el-dropdown trigger="click" v-if="item.state==1" ref="is_dom">
                <div class="describe_right">
                  <svg-icon class="f-s-20" style="color: #1966E2;margin: 2px 4px 0 0" class-name="m-r-7"
                            icon-class="appraiseshenhe"
                  />
                  <span style="cursor: pointer" @click="drop_down_box=item.planId">待审核</span>
                  <el-dropdown-menu slot="dropdown" v-show="item.planId == drop_down_box">
                    <div class="operation">
                      <p @click="planPass(item.planId,index)">通过</p>
                      <p @click="planReject(item.planId,index)">不通过</p>
                    </div>
                  </el-dropdown-menu>
                </div>
              </el-dropdown>
              <div v-else :class="item.state == 3 ? 'active1' : 'active2'">
                {{ item.state == 2 ? '不通过' : '通过' }}
              </div>
            </div>
            <!--   content     -->
            <div class="audit_content">
              <div class="data_list" v-for="(item, index) in item.contentList" :key="item.id">
                <span>{{ index + 1 }}</span>
                <span v-html="item.htmlText"></span>
              </div>
            </div>
          </div>
        </el-card>
        <div class="kong-state" v-if="!examine_list.length">
          <div class="flex f-dir align-center kong-box">
            <img class="kong" src="@/assets/appraise/icon/kongzhuangtai.png" alt=""/>
            <div class="kong-text">暂无审核内容~</div>
          </div>
        </div>
      </el-scrollbar>
    </el-main>
    <el-aside width="300px">
      <div class="right_content">
        <div
          class="right_box"
          style="cursor: pointer"
          :class="{ active: index == dynamic }"
          v-for="(item, index) in examine_nav"
          :key="item.id"
          @click="switchover(item)"
        >
          <svg-icon class="f-s-36" style="margin: 0 16px;" :icon-class="item.imgUrl"/>
          <span class="f-s-16">{{ item.name }}</span>
          <div v-if="item.num" :class="String(item.num).length === 1?'examine-num':'examine-num-1'">{{ item.num < 100?item.num:'99+' }}</div>
        </div>
      </div>
      <!--      <SideList  />-->
    </el-aside>
    <!--  个人审核驳回理由弹框  -->
    <vxe-modal class="modalBox" v-model="personaCenterDialogVisible" title="审核驳回" width="60%" height="60%" show-zoom
               resize
    >
      <template v-slot>
        <div class="personage">
          <textarea placeholder="请注明驳回原因" class="personage-text f-s-16" style="resize:none"
                    v-model="refuse_reason"
          />
          <div style="text-align: center;margin-top: 10px;">
            <el-button class="btn" size="mini" type="primary" @click="confirmSubmit">确 定</el-button>
          </div>
        </div>
      </template>
    </vxe-modal>
  </el-container>
</template>

<script>

import { syncRequest } from '@/utils/httpRequet'

export default {
  name: 'Examine',
  components: {},
  data() {
    return {
      personaCenterDialogVisible: false,
      is_state: true,
      dynamic: 0,
      state_value: '',
      state_colour: 0,
      is_hide: false,
      drop_down_box: -1,
      plan_id: '',
      plan_index: 0,
      refuse_reason: '', //驳回理由
      examine_list: [],
      examine_nav: [
        {
          id: 0,
          imgUrl: 'appraisegerennian',
          name: '审核个人年计划',
          num: 0,
        },
        {
          id: 1,
          imgUrl: 'appraisegerenyue',
          name: '审核个人月计划',
          num: 0,
        },
        {
          id: 2,
          imgUrl: 'appraisegerenzhou',
          name: '审核个人周计划',
          num: 0,
        },
        {
          id: 3,
          imgUrl: 'appraisebumennian',
          name: '审核部门年计划',
          num: 0,
        },
        {
          id: 4,
          imgUrl: 'appraisebumenyue',
          name: '审核部门月计划',
          num: 0,
        },
        {
          id: 5,
          imgUrl: 'appraisebumenzhou',
          name: '审核部门周计划',
          num: 0,
        }
      ]
    }
  },
  mounted() {
    this.init()
    this.switchover({ id:0 })
  },
  methods: {
    //初始化
    init() {
      const api_url = [
        {
          url: 'planDeptGetOrgUserYearPlan',
          data: {
            deptId: ''
          }
        },
        {
          url: 'planDeptGetOrgUserMonthPlan',
          data: {
            deptId: '',
            year: ''
          }
        },
        {
          url: 'planDeptGetOrgUserWeekPlan',
          data: {
            deptId: '',
            year: ''
          }
        },
        {
          url: 'planDeptGetOrgDeptYearPlan',
          data: {
            orgId: ''
          }
        },
        {
          url: 'planDeptGetOrgDeptMonthPlan',
          data: {
            orgId: '',
            year: ''
          }
        },
        {
          url: 'planDeptGetOrgDeptWeekPlan',
          data: {
            orgId: '',
            year: ''
          }
        }
      ]
      api_url.forEach((res, index) => {
        let plan_review = syncRequest(res)
        if (plan_review.errorCode === '1') {
          let num_list = plan_review.data.filter(item => item.state === '1')
          this.examine_nav[index].num = num_list.length
        }
      })
    },
    //时间转换
    timeToStr(type,item) {
      switch (type) {
        case 0:
        case 3:
          return item.planYear+'年'
        case 1:
        case 4:
          return item.planMonth.substring(4)+'月'
        case 2:
        case 5:
          return item.planWeek.substring(4)+'周'
      }
      return value
    },
    //计划审核通过
    planPass(id,index) {
      this.drop_down_box = -1
      const plan_pass = syncRequest({
        url: this.dynamic<3?'planUserSaveAuditInfo':'planDeptSaveAuditInfo',
        method:'post',
        data: {
          planId: id,
          state: '3'
        }
      })
      if (plan_pass.errorCode == 1) {
        this.$message.success({ message: '提交成功', center: true })
        this.examine_list[index].state = '3'
        this.refuse_reason = ''
        this.examine_nav[this.dynamic].num -= 1
      } else {
        this.$message.error({ message: '提交失败', center: true })
      }
    },
    //触发驳回弹框
    planReject(id,index) {
      this.drop_down_box = -1
      this.plan_id=id
      this.plan_index = index
      this.personaCenterDialogVisible = true
    },
    //驳回弹窗确认
    confirmSubmit() {
      const plan_reject = syncRequest({
        url: this.dynamic<3?'planUserSaveAuditInfo':'planDeptSaveAuditInfo',
        method:'post',
        data: {
          planId: this.plan_id,
          state: '2',
          refuseReason: this.refuse_reason
        }
      })
      if (plan_reject.errorCode == 1) {
        this.$message.success({ message: '提交成功', center: true })
        this.examine_list[this.plan_index].state = '2'
        this.refuse_reason = ''
        this.examine_nav[this.dynamic].num -= 1
      } else {
        this.$message.error({ message: '提交失败', center: true })
      }
      this.personaCenterDialogVisible = false
    },
    //侧边栏切换点击切换背景字体
    switchover(item) {
      this.dynamic = item.id
      const api_url = [
        {
          url: 'planDeptGetOrgUserYearPlan',
          data: {
            deptId: ''
          }
        },
        {
          url: 'planDeptGetOrgUserMonthPlan',
          data: {
            deptId: '',
            year: ''
          }
        },
        {
          url: 'planDeptGetOrgUserWeekPlan',
          data: {
            deptId: '',
            year: ''
          }
        },
        {
          url: 'planDeptGetOrgDeptYearPlan',
          data: {
            orgId: ''
          }
        },
        {
          url: 'planDeptGetOrgDeptMonthPlan',
          data: {
            orgId: '',
            year: ''
          }
        },
        {
          url: 'planDeptGetOrgDeptWeekPlan',
          data: {
            orgId: '',
            year: ''
          }
        }
      ]
      const plan_review = syncRequest(api_url[item.id])
      if (plan_review.errorCode === '1') {
        this.examine_list = plan_review.data
        if(item.name) return this.$message.success({ message: item.name, center: true })
      }
    },
    //@张娜
    handlePerson() {
    }

  }
}
</script>

<style scoped lang="scss">
.el-aside {
  background-color: #E9EEF3;
  padding: 0;
}

.el-main {
  padding-right: 10px;
}

.main-box {
  background-color: #E9EEF3;
  user-select: none;
  padding: 10px;
}

::v-deep .el-card__body {
  padding: 10px;
}
::v-deep .el-scrollbar__wrap {
  height: 100%;
  overflow-x: auto;
}
.f-s-16 {
  font-size: 16px;
}

::v-deep .el-dialog__body {
  padding: 0;
}

::v-deep .el-dialog__title {
  font-size: 20px;
  font-weight: 500;
  color: #000000;
}

/* 审核状态切换样式 */
.active {
  color: #1966E2;
  font-size: 20px;
}

.active1 {
  font-size: 20px;
  color: #00AD16;

}

.active2 {
  color: #D00000;
  font-size: 20px;
}

.el-dialog__wrapper {
  top: 4.35rem;
}

.button-top {
  width: 58px;
  height: 58px;
  position: fixed;
  bottom: 8px;
  right: 8px;
}

.examine {
  width: 100%;
  height: 100%;
  top: 110px;
  left: 0;
  background-color: #e9eef3;
  padding: 0 12px 12px 12px;
  box-sizing: border-box;
  overflow: auto;
}

.examine_box {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.examine_left {
  width: 80%;
}

.f-s-36 {
  font-size: 36px;
}

.examine_right {
  width: 19%;
  width: 19%;
  position: fixed;
  right: 15px;
  z-index: 1;
}
::v-deep .user-tag {
  color: #fff;
  background-color: #07f;
  padding: 0 5px;
  border-radius: 999em;
  display: inline-block;
  user-select: all;
}
.box-card {
  margin-bottom: 10px;
}

/*列表内容*/
.audit_data {
  width: 100%;
  box-sizing: border-box;
}

audit_data > > > .el-card.is-always-shadow {
  box-shadow: none;
}

/*herder*/
.describe {
  padding-bottom: 10px;
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.describe_left {
  display: flex;
  font-size: 14px;
  color: #666666;
}
.examine-num {
  width: 20px;
  height: 20px;
  color: #FFFFFF;
  background-color: #ee1d2d;
  border-radius: 50%;
  margin-left: 12px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.examine-num-1 {
  width: 28px;
  height: 28px;
  color: #FFFFFF;
  background-color: #ee1d2d;
  border-radius: 50%;
  margin-left: 12px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.describe_left > p:nth-child(1) > img {
  width: 14px;
  height: 14px;
}

.describe_left > p {
  display: flex;
  height: 20px;
  align-items: center;
}

.describe_left > p > img {
  display: block;
  margin-right: 10px;
}

.describe_left > p > span {
  display: block;
  font-family: '微软雅黑', Helvetica, sans-serif;
  font-size: 20px;

}

.solid {
  height: 15px;
  width: 1px;
  background: #eee;
}

.describe_right {
  height: 22px;
  display: flex;
  align-items: center;
}

.describe_right > span {
  color: #1966e2;
  font-size: 20px;
}

.name,
.job,
.year {
  font-family: '微软雅黑', Helvetica, sans-serif;
  font-size: 16px;
}

.solid {
  margin: 0 1rem;
}

/*content*/
.audit_content {
  width: 100%;
  font-family: '微软雅黑', Helvetica, sans-serif;
  line-height: 1.7;
}

.data_list {
  width: 100%;
  padding: 10px 1rem 10px 2.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
}

.data_list > span {
  display: block;
}

.f-s-20 {
  font-size: 20px;
}

.f-s-24 {
  font-size: 24px;
}

.data_list:nth-last-child(1) {
  border-bottom: none;
}

.examine_left > > > .el-card.is-always-shadow {
  box-shadow: none;
}

.data_list > span:nth-child(1) {
  width: 17px;
  height: 17px;
  opacity: 1;
  background-color: #AEB1B8;
  border-radius: 2px;
  display: inline-block;
  color: #FFFFFF;
  text-align: center;
  line-height: 17px;
  margin-right: 10px;
  font-size: 16px;
  margin-top: 6px;
}

.data_list > span:nth-child(2) {
  flex: 1;
}

.data_list > span:nth-child(2) {
  font-size: 16px;
  font-weight: 400;
  color: #333333;
}
/*空状态样式*/
.kong-state {
  display: flex;
  align-items: center;
  justify-content: center;
}

.kong {
  width: 190px;
  height: 190px;
  margin-bottom: 30px;
}

.kong-box {
  position: relative;
  top: 19px;
}

.kong-text {
  font-size: 18px;
  text-align: center;
  color: rgba(153, 153, 153, 1);
}
.align-center {
  align-items: center;
}
.f-dir {
  flex-direction: column;
}
/*操作*/
.operation {
  width: 100%;
  color: #666666;
  text-align: center;
  padding: 0 15px;
}

.operation > p {
  font-size: 18px;
  cursor: pointer;
  line-height: 30px;
}

.operation > p:nth-child(1) {
  padding: 9px 0 15px;
  border-bottom: 1px solid #eee;
}

.operation > p:nth-child(2) {
  padding: 15px 0 9px;
}

.person_body {
  width: 100%;
  height: 100%;
}

.personage {
  height: 100%;
  padding-bottom: 10px;
}

.personage-text {
  width: 100%;
  height: 90%;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.04) !important;
}

.btn {
  width: 86px;
  background: #1A66E2;
  font-size: 16px;
}

/*侧边栏*/
.right_content {
  width: 100%;
  height: 100%;
  background-color: #FFFFFF;
}

.right_box {
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
}

.right_box:hover {
  background: #f4f8ef;
}

.active {
  background: #f4f8ff;
  color: #1a65e2;
  font-size: 20px !important;
}


.right_box > span {
  display: block;
  font-size: 16px;
}

/* 审核状态切换样式 */
.active1 {
  color: #00ad16;
  font-size: 20px !important;
}

.active2 {
  color: #d00000;
  font-size: 20px !important;
}

.el-dialog__wrapper {
  top: 87px;
}
::v-deep .vxe-modal--title {
  font-size: 20px;
}
@media (max-width: 1024px) {
  .f-s-20 {
    font-size: 20px;
  }
  .f-s-16 {
    font-size: 14px;
  }
  .f-s-36 {
    font-size: 34px;
  }
  .f-s-24 {
    font-size: 22px;
  }
  ::v-deep .vxe-modal--title {
    font-size: 18px;
  }
  .operation > p {
    font-size: 16px;
    cursor: pointer;
    line-height: 30px;
  }
  .describe_left > p > span {
    display: block;
    font-family: '微软雅黑', Helvetica, sans-serif;
    font-size: 18px;
  }
  .name, .job, .year {
    font-family: '微软雅黑', Helvetica, sans-serif;
    font-size: 14px;
  }
  .describe_right > span {
    color: #1966e2;
    font-size: 18px;
  }
  .examine-num {
    width: 20px;
    height: 20px;
    color: #FFFFFF;
    background-color: #ee1d2d;
    border-radius: 50%;
    margin-left: 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .examine-num-1 {
    width: 28px;
    height: 28px;
    color: #FFFFFF;
    background-color: #ee1d2d;
    border-radius: 50%;
    margin-left: 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .data_list > span:nth-child(1) {
    width: 17px;
    height: 17px;
    opacity: 1;
    background-color: rgba(59, 117, 255, 1);
    border-radius: 2px;
    display: inline-block;
    color: #fff;
    text-align: center;
    line-height: 17px;
    margin-right: 10px;
    font-size: 14px;
    margin-top: 6px;
  }

  .data_list > span:nth-child(2) {
    font-size: 14px;
    font-weight: 400;
    color: #333333;
  }
  .operation > p {
    font-size: 14px;
    color: #666666;
    line-height: 30px;
    cursor: pointer
  }

  ::v-deep .el-dialog__title {
    font-size: 18px;
    font-weight: 500;
    color: #000000;
  }
  .btn {
    width: 86px;
    background: #1A66E2;
    font-size: 14px;
  }
  /* 审核状态切换样式 */
  .active {
    color: #1966E2;
    font-size: 20px !important;
  }

  .active1 {
    font-size: 20px !important;
    color: #00AD16;

  }

  .active2 {
    color: #D00000 !important;
    font-size: 20px;
  }
  .right_box > span {
    display: block;
    font-size: 14px;
  }
}
</style>
